package com.enjoyor.soa.traffic.core.efoms.easyrule;

import org.easyrules.annotation.Action;
import org.easyrules.annotation.Condition;
import org.easyrules.annotation.Priority;
import org.easyrules.annotation.Rule;

import com.enjoyor.soa.traffic.core.efoms.domain.RepairsRecordInfo;
import com.enjoyor.soa.traffic.core.efoms.enums.EnumDicPublic;
import com.enjoyor.soa.traffic.core.efoms.mapper.IRepairsRecordInfoMapper;

@Rule
public class AuditNopassRule {

	private String code;

	private RepairsRecordInfo repairsRecordInfo;

	private IRepairsRecordInfoMapper repairsRecordInfoMapper;

	@Condition // 判断是否符合规则；
	public boolean isAuditNoPass() {
		return code.equals(EnumDicPublic.REP_CHECKREJECT.getKey());
	}

	@Action // 命中规则后执行动作
	public void goAuditNoPass() {
		repairsRecordInfo.setOperTypeCode(EnumDicPublic.REP_OPER_CHECK.getKey());
		repairsRecordInfo.setOperTypeName(EnumDicPublic.REP_OPER_CHECK.getValue());
		repairsRecordInfo.setOperResultCode(EnumDicPublic.OPER_CHECKREJECT.getKey());
		repairsRecordInfo.setOperResult(EnumDicPublic.OPER_CHECKREJECT.getValue());
		repairsRecordInfoMapper.insertSelective(repairsRecordInfo);
	}

	public void setCode(String code) {
		this.code = code;
	}
	
	public void setRepairsRecordInfo(RepairsRecordInfo repairsRecordInfo) {
		this.repairsRecordInfo = repairsRecordInfo;
	}

	public void setRepairsRecordInfoMapper(IRepairsRecordInfoMapper repairsRecordInfoMapper) {
		this.repairsRecordInfoMapper = repairsRecordInfoMapper;
	}

	@Priority // 设置优先级，优先级 0/1/2/3..... 越小优先级越高
	public int getPriority() {
		return 3;
	}

}
